package com.wgo.precise.client.ui.view.editor.properties;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.IPropertySourceProvider;

import com.wgo.precise.client.ui.model.ClientModelItem;
import com.wgo.precise.client.ui.model.PropertyDefWrapper;
import com.wgo.precise.client.ui.view.util.PropertySourcesList;


/**
 * @author petterei
 *
 * @version $Id: ExtendedPropertySourceProvider.java,v 1.2 2006-01-30 21:52:33 petterei Exp $
 */
public class ExtendedPropertySourceProvider implements IPropertySourceProvider {
    /**
     * @see org.eclipse.ui.views.properties.IPropertySourceProvider#getPropertySource(java.lang.Object)
     */
    public IPropertySource getPropertySource(Object object) {
    	IPropertySource result = null ;
        if (object instanceof ClientModelItem) {
            result = (IPropertySource)((IAdaptable)object).getAdapter(IPropertySource.class);
        } else if (object instanceof IPropertySource) {
            result = (IPropertySource) object;
        } else if (object instanceof PropertySourcesList) {
            result = (IPropertySource) ((IAdaptable) object).getAdapter(IPropertySource.class);
        } else if (object instanceof PropertyDefWrapper) {
            result = (IPropertySource) ((IAdaptable) object).getAdapter(IPropertySource.class);
        }

        return result;
    }
    
}